Skip to content

feat(adds-on): add caching for plugin discovery#27

Merged
benbenbang merged 1 commit into
mainfrom
feat/plugin_caching
Mar 28, 2026
Merged

feat(adds-on): add caching for plugin discovery#27
benbenbang merged 1 commit into
mainfrom
feat/plugin_caching

Conversation

@benbenbang

Copy link
Copy Markdown
Owner

This pull request adds a caching mechanism to improve the performance of plugin discovery by storing discovered plugins for a configurable time-to-live period. The main changes introduce cache reading, writing, and validation logic.

Plugin cache implementation:

  • Added a constant CACHE_TTL_SECS set to 60 seconds to control cache expiration time.
  • Implemented plugin_cache_path() function to determine the cache file location at ~/.cache/uv-shell/plugins (or $XDG_CACHE_HOME/uv-shell/plugins), respecting XDG Base Directory specification.
  • Added read_plugin_cache() function to read cached plugin list, validating that the cache is fresh (within TTL) and that the PATH environment variable hasn't changed since the cache was written.
  • Implemented write_plugin_cache() function to persist discovered plugins along with a timestamp and current PATH snapshot for validation on subsequent reads.

Plugin discovery optimization:

  • Updated discover_plugins() function to check for cached results first, falling back to full PATH scanning only when cache is invalid or missing.
  • Cache automatically invalidates when PATH changes or after the TTL expires, ensuring accuracy while improving performance for repeated invocations.

This pull request adds a caching mechanism to improve the performance of plugin discovery by storing discovered plugins for a configurable time-to-live period. The main changes introduce cache reading, writing, and validation logic.

**Plugin cache implementation:**
* Added a constant `CACHE_TTL_SECS` set to 60 seconds to control cache expiration time.
* Implemented `plugin_cache_path()` function to determine the cache file location at `~/.cache/uv-shell/plugins` (or `$XDG_CACHE_HOME/uv-shell/plugins`), respecting XDG Base Directory specification.
* Added `read_plugin_cache()` function to read cached plugin list, validating that the cache is fresh (within TTL) and that the PATH environment variable hasn't changed since the cache was written.
* Implemented `write_plugin_cache()` function to persist discovered plugins along with a timestamp and current PATH snapshot for validation on subsequent reads.

**Plugin discovery optimization:**
* Updated `discover_plugins()` function to check for cached results first, falling back to full PATH scanning only when cache is invalid or missing.
* Cache automatically invalidates when PATH changes or after the TTL expires, ensuring accuracy while improving performance for repeated invocations.
@benbenbang
benbenbang enabled auto-merge (squash) March 28, 2026 10:41
@github-actions github-actions Bot added enhancement New feature or request triage labels Mar 28, 2026
@benbenbang
benbenbang merged commit 6c1c869 into main Mar 28, 2026
2 checks passed
@benbenbang
benbenbang deleted the feat/plugin_caching branch March 28, 2026 10:42
@ptah-technical-app

Copy link
Copy Markdown

🎉 This PR is included in version 2.6.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request released triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant